using System.ComponentModel;
using System.Diagnostics;
using System.Xml.Serialization;

namespace Edmx.Storage
{
    [DebuggerDisplay("Name={Name}, Type={Type}, Mode={Mode}")]
    [XmlType(Namespace = EdmxConstants.StorageSchemaNamespace)]
    public class Parameter : MetadataEntityBase<Parameter>
    {
        [XmlAttribute("Name")]
        public string Name { get; set; }

        [XmlAttribute("Type")]
        public string Type { get; set; }

        private ParameterMode? _mode;

        [XmlAttribute("Mode")]
        public ParameterMode Mode
        {
            get { return _mode ?? ParameterMode.In; }
            set { _mode = value; }
        }

        public bool ShouldSerializeMode()
        {
            return _mode.HasValue;
        }

        private int? _maxLength;

        [XmlAttribute("MaxLength")]
        public int MaxLength
        {
            get { return _maxLength ?? 0; }
            set { _maxLength = value; }
        }

        public bool ShouldSerializeMaxLength()
        {
            return _maxLength.HasValue;
        }

        private int? _precision;

        [XmlAttribute("Precision")]
        public int Precision
        {
            get { return _precision ?? 0; }
            set { _precision = value; }
        }

        public bool ShouldSerializePrecision()
        {
            return _precision.HasValue;
        }

        private int? _scale;

        [XmlAttribute("Scale")]
        public int Scale
        {
            get { return _scale ?? 0; }
            set { _scale = value; }
        }

        public bool ShouldSerializeScale()
        {
            return _scale.HasValue;
        }
    }
}